# @Author: TonghuiWu
# @Date:   2018-11-23 21:36:07
# @Last Modified by:   TonghuiWu
# @Last Modified time: 2018-11-24 00:46:10
# @E-mail: wutonghui22@163.com

import xadmin
from xadmin import views

from .models import EmailVerifyRecord, Banner


class BaseSetting(object):
    """
    后台主题显示设置
    """
    enable_themes = True    # 增加主题功能
    use_bootswatch = True    # 显示主题样式

class GlobalSettings(object):
    """
    后台标题设置
    """
    site_title = '慕学后台管理系统'   # logo
    site_footer = '慕学在线网'      #  下标主题 
    menu_style = 'accordion'       # app收纳表功能

class EmailVerifyRecordAdmin(object):
    """
    '邮箱验证码'表在后台管理中所的管理设置
    """
    list_display = ['code', 'email', 'send_type', 'send_time']   # 增加列表显示
    search_fields = ['code', 'email', 'send_type']               # 增加搜索字段
    list_filter = ['code', 'email', 'send_type', 'send_time']    # 列表过滤器

class BannerAdmin(object):
    """
    '轮播图'表在后台管理中所的管理设置
    """
    list_display = ['title','image', 'url', 'index', 'add_time']
    search_fields = ['title', 'image', 'url', 'index']
    list_filter = ['title','image', 'url', 'index', 'add_time']

# 注册表
xadmin.site.register(EmailVerifyRecord, EmailVerifyRecordAdmin)
xadmin.site.register(Banner, BannerAdmin)

# 注册基础设置
xadmin.site.register(views.BaseAdminView, BaseSetting)
xadmin.site.register(views.CommAdminView, GlobalSettings)